'use strict';

const Controller = require('egg').Controller;

class TestController extends Controller {
  /**
   * #swagger-api
   *
   * @function add
   * @memberof testController
   * @summary 添加
   * @description #tags test
   * @description #consumes application/json
   * @description #produces application/json
   * @description #parameters data body schema.test.add true - title 要添加的内容
   * @description #responses 200 schema.return - add response
   */
  async add() {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.test.add(data);
    ctx.body = res;
  }
  /**
  * #swagger-api
  *
  * @function find
  * @memberof testController
  * @summary 查询
  * @description #tags test
  * @description #consumes application/json
  * @description #produces application/json
  * @description #parameters page query schema.test.find.page true -  页码
  * @description #parameters pageSize query schema.test.find.pageSize true - 每页条数
  * @description #responses 200 schema.return - find response
  */
  async find() {
    const { ctx } = this;
    const data = ctx.query;
    const res = await ctx.service.test.find(data);
    ctx.body = res;
  }

  /**
   * #swagger-api
   *
   * @function set
   * @memberof testController
   * @summary 修改
   * @description #tags test
   * @description #consumes application/json
   * @description #produces application/json
   * @description #parameters data body schema.test.set true -  修改数据参数
   * @description #responses 200 schema.return - set response
   */
  async set() {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.test.set(data);
    ctx.body = res;
  }
  /**
   * #swagger-api
   *
   * @function del
   * @memberof testController
   * @summary 删除
   * @description #tags test
   * @description #consumes application/json
   * @description #produces application/json
   * @description #parameters data body schema.test.del true -  删除数据参数id/ids 两个参数二选一如果两个参数都传入只会删除单个id
   * @description #responses 200 schema.return - del response
   */
  async del() {
    const { ctx } = this;
    const data = ctx.request.body;
    const res = await ctx.service.test.del(data);
    ctx.body = res;
  }
}

module.exports = TestController;
